import request from './request'

/**
 * 获取收藏列表
 * @param {Object} params
 * @param {number} params.pageNum - 页码
 * @param {number} params.pageSize - 每页大小
 * @returns {Promise}
 */
export function getFavoriteList (params) {
  return request({
    url: '/favorite/list',
    method: 'get',
    params
  })
}

/**
 * 添加收藏
 * @param {Object} data - 收藏信息
 * @param {string} data.type - 类型(product/pet/service)
 * @param {number} data.targetId - 目标ID
 * @returns {Promise}
 */
export function addFavorite (data) {
  return request({
    url: '/favorite/add',
    method: 'post',
    data
  })
}

/**
 * 删除收藏
 * @param {number} id - 收藏ID
 * @returns {Promise}
 */
export function deleteFavorite (id) {
  return request({
    url: `/favorite/${id}`,
    method: 'delete'
  })
}

/**
 * 检查是否已收藏
 * @param {string} type - 类型
 * @param {number} targetId - 目标ID
 * @returns {Promise}
 */
export function checkFavorite (type, targetId) {
  return request({
    url: '/favorite/check',
    method: 'get',
    params: { type, targetId }
  })
}

